﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WMM.Tapioca.Linkbase;
using WMM.Tapioca.Instance;
using WMM.Tapioca.Taxonomy;

namespace WMM.Tapioca.Formula.Filters
{
    /// <summary>
    /// The or-filter matches facts based upon criteria expressed by any one of its sub-filters. 
    /// </summary>
    public class OrFilter : BooleanFilter
    {        
        /// <summary>
        /// Constructor.
        /// </summary>
        public OrFilter(Resource resource)
            : base(resource)
        {
            
        }

        public override List<FactItem> EvaluateFilter(VariableSet variableSet, List<FactItem> itemsToFilter, DTS dts)
        {
            List<FactItem> itemListTemp = new List<FactItem>();

            foreach (Filter subFilter in SubFilters)
            {
                itemListTemp.AddRange(subFilter.EvaluateFilter(variableSet, itemsToFilter, dts));
            }

            return itemListTemp;
        }
    }
}
